#ifndef __Game_SCENE_H__
#define __Game_SCENE_H__

#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include "CuttingPhotos.h"
#include "PreviewLayer.h"

const Color3B score_color = Color3B(30,30,30);
const Color3B return_color = Color3B(242,109,79);
const Color3B origin_color = Color3B(22,160,232);
const Color3B restart_color = Color3B(146,193,83);
const Color3B share_color = Color3B(255,105,180);

class GameScene : public cocos2d::Layer
{
public:
    // there's no 'id' in cpp, so we recommend returning the class instance pointer
    static cocos2d::Scene* createScene(int chapter, int section, int row, int col);

    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    virtual bool init(int chapter, int section, int row, int col);
    
    // a selector callback
    void touchEvent_look(Ref *pSender, cocos2d::ui::Widget::TouchEventType type);
    void touchEvent_return(Ref *pSender, cocos2d::ui::Widget::TouchEventType type);
    void touchEvent_restart(Ref *pSender, cocos2d::ui::Widget::TouchEventType type);
    void touchEvent_share(Ref *pSender, cocos2d::ui::Widget::TouchEventType type);
    
    // implement the "static create()" method manually
    static GameScene* create(int chapter, int section, int row, int col);
    
    void timeCount_update(float dt);
    
private:
    int _chapter;
    int _section;
    std::string _photoName;
    CuttingPhotos* _photo;
    PreviewLayer* _preview;
    Sprite* _decoration;
    
    ui::Button* _buttonScore;
    ui::Button* _buttonReturn;
    ui::Button* _buttonOrigin;
    ui::Button* _buttonRestart;
    ui::Button* _buttonShare;
    
    int _timeCount;
    
    bool _isWin;
    bool _isPause;
    bool _isShowing;
    bool _isMenuActioning;
    bool _isMenuShow;
    MoveBy* _moveShow;
    MoveBy* _moveHide;
    
    int _decorationIndex;
    
    std::string convertTimeFromIntToStr(int time);
    float getRealScale(int picWidth);
    void initTouchEventlistener();
    void initCustomEventListener();
    void showMenu();
    void hideMenu();
};

#endif // __Game_SCENE_H__
